layui.use(['layer','table','jquery','form'],function() {
    let layer = layui.layer,
        table = layui.table,
        $ = layui.jquery,
        form = layui.form;

    let tabInstance = table.render({
        elem: "#opptunityList1",
        url: "/sales-opportunity/listByName",
        page: true,
        id: "list",
        limits:[2,5,10,15,], //每页显示条数选择框数据
        cols: [[
            {field: 'id', title: '编号', width: 80, sort: true, fixed: 'left'},
            {field: 'opportunitySource', title: '机会来源'},
            {field: 'sname', title: '客户名称'},
            {field: 'successProbability', title: '成功机率'},
            {field: 'outline', title: '概要'},
            {field: 'contacts', title: '联系人'},
            {field: 'contactsId', title: '联系人编号'},
            {field: 'contactsTel', title: '联系电话'},
            {field: 'opportunityDesc', title: '机会描述'},
            {field: 'assignName', title: '指派人名称'},
            {field: 'foundName', title: '创建人名称'},
            {field: 'creationTime', title: '操作时间'},
            {field: 'pointTime', title: '指派时间'},
            {title: '操作', field: "right", width: 150, align: "center", toolbar: "#makeTool"}
        ]]
    });
    //监听工具条
    table.on('tool(opportunityList1)',function(obj){
        var data = obj.data; //获得当前行数据
        var layEvent = obj.event; //获得 lay-event 对应的值
        if(layEvent === 'make_btn'){
            layer.open({
                type: 2,
                content: "addPlan.jsp",
                skin: 'layui-layer-molv',
                title: "客户详细开发",
                area:["100%","100%"],
                success: function (layero, index) {
                    let body = layer.getChildFrame('body', index);
                    body.find(".id").val(data.id);
                    body.find(".opportunitySource").val(data.opportunitySource);
                    body.find(".sname").val(data.sname);
                    body.find(".successProbability").val(data.successProbability);
                    body.find(".outline").val(data.outline);
                    body.find(".contacts").val(data.contacts);
                    body.find(".contactsId").val(data.contactsId);
                    body.find(".contactsTel").val(data.contactsTel);
                    body.find(".opportunityDesc").val(data.opportunityDesc);
                    body.find(".assignName").val(data.assignName);
                    body.find(".pointTime").val(data.pointTime);
                    body.find(".foundName").val(data.foundName);
                    body.find(".creationTime").val(data.creationTime);
                }
        });
        }
    });
});